package com.example.caorl.job1to4.gateway.router;

public class RouterContext {

    public static final String STRATEGY_KEY = "routerStrategy";
    public static final String STRATEGY_RANDOM = "random";
    public static final String STRATEGY_ROUND = "round";

    private static HttpEndpointRouter randomHttpEndpointRouter = RandomHttpEndpointRouter.getInstance();
    private static HttpEndpointRouter roundRobinEndpointRouter = RoundRobinEndpointRouter.getInstance();

    private RouterContext() {
    }

    public static HttpEndpointRouter getStrategy(String strategy) {
        if (strategy == null) {
            return roundRobinEndpointRouter;
        }
        switch (strategy) {
            case STRATEGY_RANDOM:
                return randomHttpEndpointRouter;
            case STRATEGY_ROUND:
                return roundRobinEndpointRouter;
            default:
                return roundRobinEndpointRouter;
        }
    }
}
